<?php
	
	/**
	 * 
	 * @param unknown_type $pMerBillNo
	 * @return string
	 */

	function SincerityGoldUnfreeze($user_id,$platformNo,$relate_id,$deal_id,$post_url,$sys='pc'){
	
		$user = array();
		$user = get_user_info("*","id = ".$user_id);
		$user_bonus =array();
		$user_bonus = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user_bonus where id = ".$relate_id);
		//
		$Sign_data = array();
		$Sign_data['ver'] = '0.44';
		$Sign_data['mchnt_cd'] = $platformNo;// 商户编号
		$Sign_data['mchnt_txn_ssn'] = $user['id'].time();//第三方使用流水号
		$Sign_data['cust_no'] =  $user['mobile'];// 解冻目标登录账户
		$Sign_data['amt'] = $user_bonus['money'];// 金额
		$Sign_data['rem'] = '';// 商户编号
		
		/* 请求参数 */
		ksort($Sign_data);
		$Sign_old = '';
		foreach($Sign_data as $k => $v){
			if($k == 'ver'){
				$Sign_old .=$v;
				$Sign_old_a .=$k;
			}else{
				$Sign_old .= $v."|";
				$Sign_old_a .= $k."+|+";
			}
		}
		/* 签名数据 */
		$pSign=rsaSign($Sign_old,PRIVATE_KEY_PATH);
		$req = http_build_query($Sign_data)."&signature=".urlencode($pSign);
		
		$fuioupay_log = array();
		$fuioupay_log['code'] = 'UNFREEZE';
		$fuioupay_log['create_date'] = to_date(TIME_UTC,'Y-m-d H:i:s');
		$fuioupay_log['strxml'] = $req;
		$GLOBALS['db']->autoExecute(DB_PREFIX."fuioupay_log",$fuioupay_log);
		$requestNo = $GLOBALS['db']->insert_id();
		/* 调用账户查询服务 */
		$options = array(
			CURLOPT_POST => TRUE,
			CURLOPT_RETURNTRANSFER => TRUE,
			CURLOPT_SSL_VERIFYPEER=>0,
			CURLOPT_SSL_VERIFYHOST=>0,
			CURLOPT_POSTFIELDS =>$req,
		
		); 
	    $ch = curl_init($post_url); 
	    curl_setopt_array($ch,$options); 
	   	$resultStr = curl_exec($ch);
	    curl_close($ch); 
		
		if (empty($resultStr)){
				//$err_count ++ ;
			}else{
				require_once APP_ROOT_PATH.'system/collocation/fuioupay/xml.php';
				$str3ParaInfo = @XML_unserialize($resultStr);
				$str3Req = $str3ParaInfo['ap']['plain'];
				$result = array();
				$result['resp_code'] = $str3Req["resp_code"];
				$result['mchnt_cd'] = $str3Req["mchnt_cd"];
				$result['mchnt_txn_ssn'] = $str3Req["mchnt_txn_ssn"];
				$result['amt'] = $str3Req["amt"];
				$result['suc_amt'] = $str3Req["suc_amt"];
				$result['signature'] =  $str3ParaInfo['ap']['signature'];
				
				if($str3Req["resp_code"] =='0000')
				{
					//操作成功					
					$where=" platformUserNo=".$user_id." and deal_id =".$deal_id." and relate_id=".$relate_id;
					$data['status'] = 2;
					$data['create_time']=TIME_UTC;
					if (isset($str3Req['description']))
						$data['description'] = $str3Req["description"];
					$GLOBALS['db']->autoExecute(DB_PREFIX."money_freeze",$data,'UPDATE',$where);
					showIpsInfo('资金解冻成功',get_domain().APP_ROOT.'/'.URL_NAME.'?m=UserFreeze&a=index&');
					
				}else{
					$result['status'] = 0;
					return 0;
				}
					
			}
	
	}
	
	
?>